package com.kalua.list.dbaccess;

import java.time.Instant;
import java.util.Date;

import com.datastax.driver.core.Row;
import com.kalua.list.domainmodel.NumericId;

public class DBUtils {
	public static Instant getInstantFrom(Row row, String columnName) {
		Instant result;
		if (!row.isNull(columnName)) {
			Date date = row.getDate(columnName);
			result = date.toInstant();
		}
		else result = null;		
		return result;
	}

	public static NumericId getNumericIdFrom(Row row, String columnName) {
		NumericId result; 		
		if (!row.isNull(columnName))			
			result = new NumericId(row.getLong(columnName));
		else result = null;		
		return result;
	}
}
